<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            padding-bottom: 800px;
            padding-left: 30px;
        }
        .my-checkbox{
            display: inline-block;
            border: 2px solid #999;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            margin: 0px 20px;
        }
        .my-checkbox input{
            display: none;
        }
        .my-checkbox .pot{
            display: inline-block;
            width: 100%;
            height: 100%;
            background-color: green;
            border-radius: 50%;
            transform: scale(0.6);
            display: none;
        }
        .my-checkbox input:checked + span{
            display: inline-block;
        }
    </style>
</head>
<body>
    <div id="app">
        <p>flag:{{ flag }}</p>
        <input type="checkbox" v-model="flag">
        <my-checkbox :arg="flag" @update:arg=" flag=$event "></my-checkbox>
        <p>flag1:{{ flag1 }}</p>
        <input type="checkbox" v-model="flag1" true-value="是" false-value="否">
        <my-checkbox :arg="flag1" @update:arg=" flag1=$event " true-value="是" false-value="否"></my-checkbox>

        <p>arr:{{ arr }}</p>
        <input type="checkbox" value="A" v-model="arr">
        <input type="checkbox" value="B" v-model="arr">
        <input type="checkbox" value="C" v-model="arr">
        <br>
        <my-checkbox :arg="arr" @update:arg=" arr=$event " value="A" ></my-checkbox>
        <my-checkbox :arg="arr" @update:arg=" arr=$event " value="B" ></my-checkbox>
        <my-checkbox :arg="arr" @update:arg=" arr=$event " value="C" ></my-checkbox>

        <p>set:{{ set }}</p>
        <input type="checkbox" value="A" v-model="set">
        <input type="checkbox" value="B" v-model="set">
        <input type="checkbox" value="C" v-model="set">
        <br>
        <my-checkbox value="A" :arg="set" @update:arg=" set=$event "></my-checkbox>
        <my-checkbox value="B" :arg="set" @update:arg=" set=$event "></my-checkbox>
        <my-checkbox value="C" :arg="set" @update:arg=" set=$event "></my-checkbox>

    </div>

    <script type="text/x-template" id="MyCheckbox">
        <label class="my-checkbox">
            <input type="checkbox" v-model="newArg" v-bind="$attrs">
            <span class="pot"></span>
        </label>
    </script>
    <script type="module">
        // 加载 Vue3 的ESM 模块文件
        import { createApp } from "../../assets/vue3/vue.esm-browser.js"

        const MyCheckbox = {
            template:"#MyCheckbox",
            emits:["update:arg"],
            props: {
                arg: {},
            },
            computed: {
                newArg:{
                    get(){
                        return this.arg;
                    },
                    set(nv){
                        // console.log(nv);
                        this.$emit("update:arg",nv)
                    }
                }
            },
        }

        createApp({
            components: {
                MyCheckbox,
            },
            data(){
                return {
                    flag:false,
                    flag1:"否",
                    arr:[],
                    set:new Set([])
                }
            }
        }).mount("#app")
    </script>
</body>
</html>